
const getComp = (selector, comp = getCurrentPages()[getCurrentPages().length - 1]) => {
   const component = comp.selectComponent(selector)
   // console.log(component)
   if (!component) {
      throw new Error('未找到对应的组件')
   }
   return component
}

const $mpwToast = (selector = '#mpw-toast', comp) => getComp(selector, comp)
const $mpwDialog = (selector = '#mpw-dialog', comp) => getComp(selector, comp)
const $mpwPopup = (selector = '#mpw-popup', comp) => getComp(selector, comp)
const $mpwSpreads = (selector = '#mpw-spreads', comp) => getComp(selector, comp)
const $mpwTips = (selector = '#mpw-tips', comp) => getComp(selector, comp)
const $mpwMessage = (selector = '#mpw-message', comp) => getComp(selector, comp)
const $mpwTabbar = (selector = '#mpw-tabbar', comp) => getComp(selector, comp)
const $mpwSheet = (selector = '#mpw-sheet', comp) => getComp(selector, comp)
const $stopMpwRefresher = (selector = '#mpw-refresh', comp) => getComp(selector, comp).refreshSuccess()



export {
  $mpwToast,
  $mpwDialog,
  $mpwPopup,
  $mpwSpreads,
  $mpwTips,
  $mpwMessage,
  $mpwTabbar,
  $mpwSheet,
  $stopMpwRefresher
}